package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.ShareMagCountEntity;
import com.sgb.knowledgeshare.view.fragment.ShareMessageFragment;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ShareMessageModel extends ViewModel {
    ShareMessageFragment fragment;
    public void setActivity(ShareMessageFragment shareMessageFragment) {
        fragment = shareMessageFragment;
    }

    //获取当前用户未读消息数量
    public void getMsgCount() {
        ShareConfig.getInstance().getApi().getMsgCount().enqueue(new ICallBack<BaseEntity<ShareMagCountEntity>>() {
            @Override
            public void onSuccess(BaseEntity<ShareMagCountEntity> data) {
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    fragment.setCount(data.getData());
                }
            }
        });

    }


}
